package com.example.wnn.utils;

import cn.hutool.core.map.MapUtil;
import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import cn.hutool.http.HttpStatus;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;

import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;

public class HttpUtils {


    public static void main(String[] args) {

        try {
            InetAddress addr = InetAddress.getLocalHost();
            System.out.println(addr);
            System.out.println(addr.getHostAddress());
            System.out.println(addr.getHostName());
        } catch (UnknownHostException e) {
            e.printStackTrace();
        }


    }

    static class ThreadA extends Thread {

        @Override
        public void run() {

            for (int i =0;i<1000;i++){
                Map<String,Object> body = new HashMap<>();
                body.put("contentId","39762c127e1e46118ede106382790dbd");
                String deviceId = UUID.randomUUID().toString().replace("-","");
                HttpResponse response = HttpRequest.post("https://health-api-pre.tikrnews.com/cms/api/content/detail")
                        .header("deviceid", deviceId)
                        .header("Content-Type", "application/json")
                        .body(JSONUtil.toJsonStr(body), "application/json")
                        .execute();

                if (response.getStatus() == HttpStatus.HTTP_OK) {
                    JSONObject object = JSONUtil.parseObj(response.body());
                    System.out.println(object);
                }

            }

        }

    }

}
